package com.wy.projectssj.service.impl;

import com.wy.projectssj.dao.PermissionDao;
import com.wy.projectssj.dao.impl.PermissionRoleDaoImpl;
import com.wy.projectssj.domain.Permission;
import com.wy.projectssj.service.PermissionService;
import com.wy.projectssj.utils.Uuid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: wy
 * @Date:2019/8/30 14:04
 */
@Service
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionDao permissionDao;
    @Autowired
    private PermissionRoleDaoImpl permissionRoleDao;
    @Override
    public List<Permission> findAll() {
        return permissionDao.findAll();
    }

    @Override
    public int save(Permission permission) {
         permission.setId(Uuid.getUuid());
        return permissionDao.save(permission);
    }

    @Override
    public int delete(String[] ids) {
          int result=-1;
        if(ids!=null&&ids.length>0){
            permissionRoleDao.deleteByPid(ids);
            result= permissionDao.delete(ids);
        }
          return  result;
    }
}
